<!DOCTYPE html>
<html lang="en">

<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>Document</title>
</head>

<body>
	<script>
		function Parent() {

		}
		// 将要继承的属性赋给prototype属性
		Parent.prototype.money = 100000
		Parent.prototype.head = 1

		function Child(name, age) {
			this.name = name
			this.age = age
		}

		// 空对象 几乎不占内存 解决父类构造器同步改变
		function extend(Son, Father) {
			var N = function () { }
			N.prototype = Father.prototype
			Son.prototype = new Father()
		}
		// 依然会造成继承链紊乱 
		extend(Child, Parent)
		var son = new Child('jiffy', 22)
		// 手动拨正
		Child.prototype.constructor = Child


		alert(Child.prototype.constructor)
		alert(Parent.prototype.constructor)
		alert(son.name)
		alert(son.age)
		alert(son.money)
		alert(son.head)

	</script>
</body>

</html>